var Customer = {
    id: "CustomerTable",
    seItem: null,
    table: null,
    layerIndex: -1
};
var windowNameIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引

function _formatter(value, row, index) {
    if (row.accountArrears > 0) {
        return '<span style="color: red" title="' + value + '">' + value + '</span>'
    } else {
        return '<span title="' + value + '">' + value + '</span>'
    }
}

function _formatterTime(value, row, index) {
    if (row.accountArrears > 0) {
        if (value != null && value !== "") {
            return "<span style='color: red'>" + value.substring(0, 19) + "</span>"
        } else {
            return "";
        }
    } else {
        if (value != null && value !== "") {
            return value.substring(0, 19)
        } else {
            return "";
        }
    }
}

Customer.initColumn = function () {
    var columns = [{
        field: 'selectItem',
        radio: true
    }, {
        title: 'id',
        field: 'id',
        visible: false,
        align: 'center',
        valign: 'middle'
    }, {
        title: 'customerSexHead',
        field: 'customerSexHead',
        visible: false,
        align: 'center',
        valign: 'middle'
    }, {
        title: 'checkStatus',
        field: 'checkStatus',
        visible: false,
        align: 'center',
        valign: 'middle'
    }, {
        title: 'reservationsId',
        field: 'reservationsId',
        visible: false,
        align: 'center',
        valign: 'middle'
    },  {
        title: 'orthodonticsStatus',
        field: 'orthodonticsStatus',
        visible: false,
        align: 'center',
        valign: 'middle'
    },{
        title: '病历号',
        field: 'medicalRecordNumber',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 120,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '姓名',
        field: 'customerName',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 120,
        formatter: function (value, row, index) {
            if (row.accountArrears > 0) {
                if (row.orthodonticsStatus > 0) {
                    return "<a href='javascript:;' style='color: red;display: flex;align-items: center;' onclick = 'Customer.openBilee(" + '"' + row.id + '"' + ")' ><img src='" + row.customerSexHead + "' alt='' width='40px'><span class='portraitHeadName'>" + value + "</span><img src=\"https://pynnn.oss-cn-hangzhou.aliyuncs.com/ychh001.png\" alt=\"...\" width=\"18px;\"></a>"
                }else {
                    return "<a href='javascript:;' style='color: red;display: flex;align-items: center;' onclick = 'Customer.openBilee(" + '"' + row.id + '"' + ")' ><img src='" + row.customerSexHead + "' alt='' width='40px'><span class='portraitHeadName'>" + value + "</span></a>"
                }
            } else {
                if (row.orthodonticsStatus > 0) {
                    return "<a href='javascript:;' style='display: flex;align-items: center;' onclick = 'Customer.openBilee(" + '"' + row.id + '"' + ")' ><img src='" + row.customerSexHead + "' alt='' width='40px'><span class='portraitHeadName'>" + value + "</span><img src=\"https://pynnn.oss-cn-hangzhou.aliyuncs.com/ychh001.png\" alt=\"...\" width=\"18px;\"></a>"
                }else {
                    return "<a href='javascript:;' style='display: flex;align-items: center;' onclick = 'Customer.openBilee(" + '"' + row.id + '"' + ")' ><img src='" + row.customerSexHead + "' alt='' width='40px'><span class='portraitHeadName'>" + value + "</span></a>"
                }
            }
        }
    }, {
        title: '电话',
        field: 'customerPhone',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 140,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '电话2',
        field: 'customerPhone2',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 135,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '使用人',
        field: 'phoneSharShip',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 90,
        formatter: function (value, row, index) {
            if (row.checkStatus === 1) {
                if (row.accountArrears > 0) {
                    return '<span style="color: red" title="' + value + '">' + value + '<span style="color: white;background: #FF7E00;padding: 0 2px;border-radius: 50%;margin-left: 4px;">查</span></span>'
                } else {
                    return '<span title="' + value + '">' + value + '<span style="color: white;background: #FF7E00;padding: 0 2px;border-radius: 50%;margin-left: 4px;">查</span></span>'
                }
            } else {
                if (row.accountArrears > 0) {
                    return '<span style="color: red" title="' + value + '">' + value + '</span>'
                } else {
                    return '<span title="' + value + '">' + value + '</span>'
                }
            }
        }
    }, {
        title: '性别',
        field: 'sex',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 80,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '年龄',
        field: 'customerAge',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 80,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '科室',
        field: 'treatmentUnit',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 100,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '一级渠道',
        field: 'oneChannel',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 110,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '二级渠道',
        field: 'twoChannel',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 110,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '三级渠道',
        field: 'thrChannel',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 130,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '客户状态',
        field: 'customerStatus',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 110,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '开单状态',
        field: 'dealStatus',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 110,
        formatter: function (value, row, index) {
            if (value === "已结账") {
                if (row.accountArrears > 0) {
                    return "<a href='javascript:;' style='color: red' onclick='Customer.opendealStatus(" + '"' + row.reservationsId + '"' + ")'>[已结账]</a>"
                } else {
                    return "<a href='javascript:;' onclick='Customer.opendealStatus(" + '"' + row.reservationsId + '"' + ")'>[已结账]</a>"
                }
            } else if (value !== "已结账") {
                return _formatter(value, row, index)
            }
        }
    }, {
        title: '扫码状态',
        field: 'oppStatus',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 110,
        formatter: function (value, row, index) {
            if(value === "" || value === undefined || value === null){
                return "未扫码"
            }else {
                return "已扫码"
            }
        }
    }, {
        title: '已交金额',
        field: 'actualAccountBalance',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 110,
        formatter: function (value, row, index) {
            if (row.accountArrears > 0) {
                return "<a href='javascript:;' style='color: red'>" + (value + row.moneyBalance+ parseFloat(row.orthodonticsStatus)) + "</a>"
            } else {
                return (value + row.moneyBalance+parseFloat(row.orthodonticsStatus))
            }
        }
    }, {
        title: '欠费',
        field: 'accountArrears',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 100,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '现场TC',
        field: 'fieldTc',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 100,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '医生',
        field: 'doctor',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 100,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    },{
        title: '导医',
        field: 'guideDoctor',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 100,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    },{
        title: '无龋齿儿童',
        field: 'childrenCard',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 100,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '到店时间',
        field: 'arrivalTime',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 170,
        formatter: function (value, row, index) {
            return _formatterTime(value, row, index)
        }
    }, {
        title: '初诊时间',
        field: 'firstVisitDate',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 110,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '黄页编号',
        field: 'yellowNumber',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 140,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '备注',
        field: 'remarks',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 120,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        },
        cellStyle: function (value, row, index) {
            return {css: {"overflow": "hidden", "white-space": "nowrap", "text-overflow": "ellipsis"}}
        }
    }, {
        title: '网电咨询师',
        field: 'scarchiving',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 130,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '一级媒介',
        field: 'oneMedium',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 130,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '二级媒介',
        field: 'twoMedium',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 130,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }, {
        title: '三级媒介',
        field: 'thrMedium',
        align: 'center',
        valign: 'middle',
        sortable: true,
        width: 130,
        formatter: function (value, row, index) {
            return _formatter(value, row, index)
        }
    }];
    return columns
};

Customer.choiceTc = function (id) {
    $.ajax({
        url: Feng.ctxPath + "/customer/getCustomerIsDealStatus/" + id,
        type: "post",
        success: function (data) {
            if (data == 1) {
                alert("此患者已开单不能修改TC！");
                return false
            } else {
                var index = layer.open({
                    type: 2,
                    title: '选择Tc',
                    area: ['50%', '60%'],
                    fix: true,
                    maxmin: true,
                    content: Feng.ctxPath + '/customer/to_choiceTc/' + id
                });
                this.layerIndex = index
            }
        },
        error: function (data) {
            alert('没有权限，请联系系统管理员!');
            parent.layer.close(windowNameIndex)
        }
    })
};

Customer.formParams = function () {
    var queryData = {};
    queryData['sreach'] = $("#sreach").val();
    queryData['customerName'] = $("#customerName").val();
    queryData['customerPhone'] = $("#customerPhone").val();
    queryData['startArrivalTime'] = $("#startArrivalTime").val();
    queryData['endArrivalTime'] = $("#endArrivalTime").val();
    queryData['reservations'] = $("#reservations").val();
    queryData['startRevisitTime'] = $("#startRevisitTime").val();
    queryData['endRevisitTime'] = $("#endRevisitTime").val();
    queryData['fieldTc'] = $("#fieldTc").val();
    queryData['oppStatus'] = $("#oppStatusValue").val();
    queryData['doctor'] = $("#doctor").val();
    queryData['dealStatus'] = $("#dealStatus").val();
    queryData['customerStatus'] = $("#customerStatus").val();
    queryData['treatmentUnit'] = $("#treatmentUnit").val();
    queryData['startAddTime'] = $("#startAddTimeValue").val();
    queryData['endAddTime'] = $("#endAddTimeValue").val();
    queryData['startUpdateTime'] = $("#startUpdateTimeValue").val();
    queryData['endUpdateTime'] = $("#endUpdateTimeValue").val();
    queryData['oneChannel'] = multipleSelection($('#oneChannel').val());
    queryData['twoChannel'] = multipleSelection($('#twoChannel').val());
    queryData['thrChannel'] = multipleSelection($('#thrChannel').val());
    queryData['abbreviation'] = $("#abbreviation", parent.document).val();
    console.log(queryData);
    return queryData
};

var parseParam = function (param) {
    var paramStr = "";
    $.each(param, function (i) {
        paramStr += '&' + getSingleData(param, i)
    });
    return paramStr.substr(1)
};
var getSingleData = function (param, key) {
    return key + "=" + param[key]
};

Customer.upload = function () {
    var index = layer.open({
        type: 2,
        title: '导入',
        area: ['70%', '80%'],
        fix: true,
        maxmin: true,
        content: Feng.ctxPath + '/customerUpload/customer_import'
    });
    this.layerIndex = index
};

Customer.customerExport = function () {
    var param = parseParam(Customer.formParams());
    location.href = Feng.ctxPath + '/customer/customerExport?' + param;
};

Customer.resetSearch = function () {
    $("#sreach,#customerName,#customerPhone,#startArrivalTime,#endArrivalTime,#reservations,#fieldTc,#doctor,#customerStatus," +
        "#dealStatus,#startRevisitTime,#endRevisitTime,#startAddTimeValue,#endAddTimeValue,#startUpdateTimeValue,#endUpdateTimeValue").val("");
    $('#oneChannel').selectpicker('val', ['noneSelectedText']);
    $('#twoChannel').selectpicker('val', ['noneSelectedText']);
    $('#thrChannel').selectpicker('val', ['noneSelectedText']);
    $(".timeBox > div button").removeClass('actionClick');
    Customer.search()
};

Customer.opendealStatus = function (id) {
    $.ajax({
        url: Feng.ctxPath + "/reservations/getTotleMoneys",
        type: "post",
        data: {
            "id": id
        },
        success: function (data) {
            alert("成交金额：" + data + "元")
        },
        error: function (data) {
            alert('没有权限，请联系系统管理员!');
            parent.layer.close(windowNameIndex)
        }
    })
};

Customer.inputInfo = function () {
    var index = layer.open({
        type: 2,
        title: '批量上传',
        area: ['90%', '90%'],
        maxmin: true,
        content: Feng.ctxPath + '/recharge/customerInfo_import/'
    });
    this.layerIndex = index
};

Customer.shortMessage = function () {
    if (this.check()) {
        var customerId = Customer.seItem.id;
        var index = layer.open({
            type: 2,
            title: '发送消息',
            area: ['60%', '80%'],
            fix: true,
            maxmin: true,
            content: Feng.ctxPath + '/msgSend/to_msgSend/' + customerId
        });
        this.layerIndex = index
    }
};

Customer.updateTochoiceTc = function () {
    if (this.check()) {
        var id = Customer.seItem.id;
        $.ajax({
            url: Feng.ctxPath + "/customer/getCustomerIsDealStatus/" + id,
            type: "post",
            success: function (data) {
                if (data == 1) {
                    alert("此患者已开单不能修改TC！");
                    return
                } else {
                    var index = layer.open({
                        type: 2,
                        title: '选择Tc',
                        area: ['50%', '60%'],
                        fix: true,
                        maxmin: true,
                        content: Feng.ctxPath + '/customer/to_choiceTc/' + id
                    });
                    this.layerIndex = index
                }
            },
            error: function (data) {
                alert('没有权限，请联系系统管理员!');
                parent.layer.close(windowNameIndex)
            }
        })
    }
};

Customer.msgSend = function () {
    var customerId = $("#customerId").val();
    var customerName = $("#customerName").val();
    var customerPhone = $("#customerPhone").val();
    var messageContent = $("#message_content").val();
    var outpatientName = $("#outpatientName").val();
    var transportation = $("#transportationValue").val();
    var address = $("#address").val();
    var phone = $("#phone").val();
    var time = $("#startTimeValue1").val();
    var doctor = $("#doctorValue1").val();
    var templateCode = $("#templateCodeValue").val();
    var smsParameterId = $("#smsParameterId").val();
    if (confirm("发送信息给【" + customerName + "】?")) {
        $.ajax({
            url: Feng.ctxPath + "/msgSend/msgSend",
            type: "post",
            data: {
                customerId: customerId,
                messageContent: messageContent,
                templateCode: templateCode,
                customerPhone: customerPhone,
                outpatientName: outpatientName,
                address: address,
                phone: phone,
                time: time,
                doctor: doctor,
                customerName: customerName,
                transportation: transportation,
                smsParameterId:smsParameterId
            },
            success: function (data) {
                if(data==-1){
                    alert("手机号码格式不正确");
                }else{
                    Feng.success('操作成功!');
                    Customer.close()
                }
            },
            error: function (data) {
                alert('没有权限，请联系系统管理员!');
                parent.layer.close(windowNameIndex)
            }
        })
    }
};

Customer.sendMedicalAdvice = function () {
    var customerPhone = $("#customerPhone").val();
    var index = layer.open({
        type: 2,
        title: '诉后医嘱',
        area: ['70%', '80%'],
        fix: true,
        maxmin: true,
        content: Feng.ctxPath + '/customer/to_sendMedicalAdvice/' + customerPhone
    });
    this.layerIndex = index
};

Customer.openBilee = function (ide) {
    $.ajax({
        url: Feng.ctxPath + "/consultantTwo/getdcsByCustomerId",
        type: "post",
        data: {
            "id": ide
        },
        success: function (data) {
            if (data == 1) {
                var index = layer.open({
                    type: 2,
                    title: '到店客户详情',
                    area: ['100%', '100%'],
                    fix: true,
                    maxmin: true,
                    content: Feng.ctxPath + '/customerDetails/to_openBileLists/' + ide + "/0"
                });
                this.layerIndex = index
            } else {
                alert("请先联系前台客服匹配建档！");
                return
            }
        }
    })
};

Customer.dealUpload = function () {
    var index = layer.open({
        type: 2,
        title: '开单数据',
        area: ['70%', '80%'],
        fix: true,
        maxmin: true,
        content: Feng.ctxPath + '/recharge/dealInfo_import/'
    });
    this.layerIndex = index
};

Customer.to_generateQrCode = function () {
    if (this.check()) {
        var id = Customer.seItem.id;
        var reservationsId = Customer.seItem.reservationsId;
        $.ajax({
            url: Feng.ctxPath + "/customer/getMemberStatus",
            type: "post",
            data: {
                "reservationsId": reservationsId
            },
            success: function (data) {
                if (data == 1) {
                    var index = layer.open({
                        type: 2,
                        title: '&nbsp',
                        area: ['70%', '80%'],
                        fix: true,
                        maxmin: true,
                        content: Feng.ctxPath + '/customer/to_generateQrCode/' + id
                    });
                    this.layerIndex = index
                } else {
                    alert("已经扫码注册了！");
                    return
                }
            }
        })
    }
};

Customer.openBillingJY = function () {
    if (this.check()) {
        var customerId = Customer.seItem.id;
        var index = layer.open({
            type: 2,
            title: '&nbsp',
            area: ['100%', '100%'],
            fix: true,
            maxmin: true,
            content: Feng.ctxPath + '/consultantDetails/consultantToDetailByTab/' + customerId + '/0/0'
        });
        this.layerIndex = index
    }
};

Customer.addTreatmentUnit = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '增加科室',
            area: ['60%', '50%'],
            fix: true,
            maxmin: true,
            content: Feng.ctxPath + '/customer/add_TreatmentUnit/' + Customer.seItem.id
        });
        this.layerIndex = index
    }
};

Customer.close = function () {
    parent.layer.close(windowNameIndex)
};

Customer.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录！");
        return false
    } else {
        Customer.seItem = selected[0];
        return true
    }
};

Customer.search = function () {
    Customer.table.refresh({
        query: Customer.formParams()
    });
    Customer.total();
    Customer.totalSweep();
};

Customer.searchrefresh = function () {
    Customer.table.refresh({
        query: Customer.formParams()
    });
};

Customer.total = function () {
    var startArrivalTime = $("#startArrivalTime").val();
    var endArrivalTime = $("#endArrivalTime").val();
    var valueOne = multipleSelection($('#oneChannel').val());
    var valueTwo = multipleSelection($('#twoChannel').val());
    var valueThr = multipleSelection($('#thrChannel').val());
    var dealStatus = $("#dealStatus").val();
    var oppStatus = $("#oppStatusValue").val();
    var fieldTc = $("#fieldTc").val();
    var doctor = $("#doctor").val();
    var treatmentUnit = $("#treatmentUnit").val();
    var sreach = $("#sreach").val();
    $.ajax({
        type: "GET",
        url: Feng.ctxPath + "/customer/total",
        data: {
            startArrivalTime: startArrivalTime,
            endArrivalTime: endArrivalTime,
            oneChannelValue: valueOne,
            twoChannelValue: valueTwo,
            thrChannelValue: valueThr,
            fieldTc: fieldTc,
            doctor: doctor,
            treatmentUnit: treatmentUnit,
            sreach: sreach,
            dealStatus: dealStatus,
            oppStatus:oppStatus
        },
        dataType: "json",
        success: function (data) {
            $("#total").html(data[0].countNum);
            $("#first").html(data[1].countNum);
            $("#two").html(data[2].countNum);
            $("#further").html(data[3].countNum);
            $("#old").html(data[4].countNum);
            $("#fzsum").html(data[5].countNum)
        }
    })
};
Customer.totalSweep = function () {
    $.ajax({
        type: "GET",
        url: Feng.ctxPath + "/customer/scanCode",
        data: {
            startUpdateTime1: setDateTime(new Date(), 0) + " 00:00:00",
            endUpdateTime1: setDateTime(new Date(), 0) + " 23:59:59",
            startUpdateTime2: firstMonthTime(new Date(), 0) + " 00:00:00",
            endUpdateTime2: setMonthTime(new Date(), 0) + " 23:59:59",
            startAddTime1: setDateTime(new Date(), 0) + " 00:00:00",
            endAddTime1: setDateTime(new Date(), 0) + " 23:59:59",
            startAddTime2: firstMonthTime(new Date(), 0) + " 00:00:00",
            endAddTime2: setMonthTime(new Date(), 0) + " 23:59:59"
        },
        dataType: "json",
        success: function (data) {
            $("#todayCode").html(data[0].countNum);
            $("#monthCode").html(data[1].countNum);
            $("#todayRegister").html(data[2].countNum);
            $("#monthRegister").html(data[3].countNum);
        }
    })
};

Customer.totalNumber = function (ojb) {
    $("#customerStatus").val(ojb);
    Customer.search()
};

Customer.sweepCode = function (ojb) {
    if(ojb === '今日扫码'){
        $("#startUpdateTimeValue").val(setDateTime(new Date(), 0) + " 00:00:00");
        $("#endUpdateTimeValue").val(setDateTime(new Date(), 0) + " 23:59:59");
    }else if(ojb === '本月扫码'){
        $("#startUpdateTimeValue").val(firstMonthTime(new Date(), 0) + " 00:00:00");
        $("#endUpdateTimeValue").val(setMonthTime(new Date(), 0) + " 23:59:59");
    }
    $("#customerStatus,#startAddTimeValue,#endAddTimeValue,#startArrivalTime,#endArrivalTime").val("");
    Customer.search();
};

Customer.register = function (ojb) {
    if(ojb === '今日注册'){
        $("#startAddTimeValue").val(setDateTime(new Date(), 0) + " 00:00:00");
        $("#endAddTimeValue").val(setDateTime(new Date(), 0) + " 23:59:59");
    }else if(ojb === '本月注册'){
        $("#startAddTimeValue").val(firstMonthTime(new Date(), 0) + " 00:00:00");
        $("#endAddTimeValue").val(setMonthTime(new Date(), 0) + " 23:59:59");
    }
    $("#customerStatus,#startUpdateTimeValue,#endUpdateTimeValue,#startArrivalTime,#endArrivalTime").val("");
    Customer.search();
};

Customer.naturalDaySearch = function (obj) {
    if (obj == 1) {
        $("#startArrivalTime").val(setDateTime(new Date(), 0) + " 00:00:00");
        $("#endArrivalTime").val(setDateTime(new Date(), 0) + " 23:59:59");
        $(".timeBox > div button").eq(0).addClass('actionClick').siblings().removeClass('actionClick')
    } else if (obj == 2) {
        var AccountsTime = $("#sttleAccountsTime").val();
        $("#startArrivalTime").val(setDateTime(new Date(), 1) + " " + AccountsTime);
        $("#endArrivalTime").val(setDateTime(new Date(), 0) + " " + AccountsTime);
        $(".timeBox > div button").eq(1).addClass('actionClick').siblings().removeClass('actionClick')
    };
    Customer.search();
};

function phonePrivileges(){   //隐藏手机号
    var phonePrivileges=parent.$("#phonePrivileges").val();
    if(phonePrivileges == 2){
        $('#CustomerTable').bootstrapTable('hideColumn', 'customerPhone');
    }
}

$(function () {
    var defaultColunms = Customer.initColumn();
    var table = new BSTable(Customer.id, "/customer/list", defaultColunms);
    table.setPaginationType("server");
    table.setQueryParams(Customer.formParams());
    Customer.table = table.init();
    Customer.naturalDaySearch(1);
    menuNameHideColumn($("#menuName").val(), 'CustomerTable');
    $("#oneChannel").change(function () {
        $("#twoChannel").val('请选择');
        $("#thrChannel").val('请选择');
        Customer.search();
    });
    $("#twoChannel").change(function () {
        $("#thrChannel").val('请选择');
        Customer.search();
    });
    $("#thrChannel").change(function () {
        Customer.search();
    });
    $(document).on('click', '#laydate_clear,#laydate_today,#laydate_ok', function () {
        Customer.search();
    });
    checkDate = function () {
        Customer.search();
    };
    phonePrivileges();
});
